package com.yy.controller;

import com.yy.service.CuratorStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: chen
 * @Date: 2022/9/24 19:56
 * @Desc: curator 功能测试
 */
@RestController
@RequestMapping("/curator")
public class CuratorTestController {
    @Autowired
    CuratorStockService stockService;

    @GetMapping("/stock/deduct")
    public String deduct() {
        stockService.interProcessMutex();
        return "product stock deducted";
    }

    @GetMapping("/semaphore/lock")
    public String semaphoreLock() {
        stockService.interProcessSemaphoreV2();
        return "test semaphore lock";
    }


    @GetMapping("/read/lock")
    public String readLock() {
        stockService.interProcessReadLock();
        return "test read lock";
    }

    @GetMapping("/write/lock")
    public String readWrite() {
        stockService.interProcessWriteLock();
        return "test write lock";
    }

    @GetMapping("/share/count")
    public String fairLock() {
        stockService.shareCount();
        return "test share count lock";
    }

/*




    @GetMapping("/latch/lock")
    public String latchLock() {
        stockService.latchLock();
        return "人到齐了,开始播放电影";
    }

    @GetMapping("/countDown/lock")
    public String countDownLock() {
        stockService.countDownLock();
        return Thread.currentThread().getName() + ": 进入了电影院";
    } */
}
